<?php
declare (strict_types = 1);

namespace app\mini\controller;

use app\admin\model\Setting;
use app\admin\model\Slideshow;
use app\crm\model\ShortMessageTplModel;
use app\mini\model\CustomerPointGoodsBuy;
use app\mini\model\CustomerPointLogModel;
use app\mini\model\CustomerPointModel;
use app\mini\model\CustomerSign;
use app\mini\model\MiniPrizeLog;
use think\response\Json;
use app\mini\model\SysModelMiniAdmin;
use app\crm\model\Customer as CustomerModel;
use app\mini\model\PersonCustomer;
use app\crm\model\Setting as SettingModel;
use app\mini\model\PersonCase as PersonCaseModel;
use app\crm\model\ReturnVist;
use app\admin\model\File as FileModel;
use app\mini\model\AddModel;
use app\admin\model\ShopOrderModel as AdminShopOrderModel;

use think\facade\Db;

/**
 * Class Index
 * @package app\mini\controller
 * @author Mr.Liu Wuchen
 * @create 2024-01-016 10:42
 */
class IndexAdmin extends Access
{
    // -----------------------------------------------------成交数据-----------------------------------------------
    // 成交数据-总成交-店均成交个数
    public function getCJTotal()
    {
        $request = $this->request->param();

        $model = new SysModelMiniAdmin();

        $data = $model->getCJTotal($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // 市场/门店业绩
    public function getcjGrade()
    {
        $request = $this->request->param();

        $model = new SysModelMiniAdmin();

        $data = $model->getcjGrade($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // ---------------------------------------------------体验成交------------------------------------------------
    // 市场/门店业绩
    public function getTiyanChengjiaoGrade()
    {
        $request = $this->request->param();

        $model = new SysModelMiniAdmin();

        $data = $model->getTiyanChengjiaoGrade($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);

    }

    // 成交分类
    public function getCJtypeRate()
    {
        $request = $this->request->param();

        $request['pc'] = 1;

        $request['startTime'] = $request['start_time'];

        $request['endTime'] = $request['end_time'];

        $model = new AdminShopOrderModel();

        $data = $model->getShopOrderCommonDataCollect($request['shop_ids'],$request);

        return resultArray(['data' => $data,'error'=>'获取成功']);

    }

    // 成交分类
    public function getMarketCJtypeRate()
    {
        
        $request = $this->request->param();

        $model = new SysModelMiniAdmin();

        $data = $model->getMarketCJtypeRate($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);

    }

    // 客户数据-客户数据（echarts）
    public function getComeInEcharts()
    {
        $request = $this->request->param();

        $model = new SysModelMiniAdmin();

        $data = $model->getComeInEcharts($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // --------------------------------------------------------------客户数据---------------------------------------------------------
    // 客户数据-进店数据（市场/门店列表）
    public function getComeInList()
    {
        $request = $this->request->param();

        $model = new SysModelMiniAdmin();

        $data = $model->getComeInList($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // 客户数据-客户数据（流失保有）
    public function getCustomerData()
    {
        $request = $this->request->param();

        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;

        $model = new SysModelMiniAdmin();

        $data = $model->getCustomerData($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // 客户数据-客户分类（ABC）
    public function getCustomerType()
    {
        $request = $this->request->param();

        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;

        $model = new SysModelMiniAdmin();

        $data = $model->getCustomerType($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // 客户数据-二次开发率/项目普及率/功效满意度
    public function getErci()
    {
        $request = $this->request->param();

        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;

        $model = new SysModelMiniAdmin();

        $data = $model->getErci($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // ------------------------------------------------------------业绩数据----------------------------------------------
    public function getTotalPerformanceEcharts()
    {
        $request = $this->request->param();

        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;

        $model = new SysModelMiniAdmin();

        $data = $model->getTotalPerformanceEcharts($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    public function getTotalPerformance()
    {
        $request = $this->request->param();

        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;

        $model = new SysModelMiniAdmin();

        $data = $model->getTotalPerformance($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    public function getScarAndProjectMoney()
    {
        $request = $this->request->param();

        $model = new SysModelMiniAdmin();

        $data = $model->getScarAndProjectMoney($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    // ==================================================================二级页面================================================================
    public function readAdminCustomerByShopId()
    {
        $request = $this->request->param();

        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;

        $model = new SysModelMiniAdmin();

        $data = $model->readAdminCustomerByShopId($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

}